package io.renren.modules.dangan.bean;

import io.renren.modules.dangan.entity.DaServerEntity;
import io.renren.modules.dangan.utils.FtpUtils;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.Callable;
@Slf4j
public class FileMoverRunnable implements Callable<Boolean> {

    private DaServerEntity oaFtpServer;
    private String srcFileName,srcPath,destPath;

    public FileMoverRunnable(DaServerEntity oaFtpServer, String srcFileName, String srcPath, String destPath) {
        this.oaFtpServer = oaFtpServer;
        this.srcFileName = srcFileName;
        this.srcPath = srcPath;
        this.destPath = destPath;
    }

    @Override
    public Boolean call() throws Exception {
        try {
            System.out.println("开始执行文件拷贝任务"+srcFileName+srcPath+"-"+destPath+"-"+oaFtpServer.toString());
           return  FtpUtils.downloadOaFileFromFtp(oaFtpServer,srcPath,srcFileName,destPath,srcFileName);
        }catch (Exception e){
            System.out.println(e);
            log.error(e.getMessage(),e);
            return false;
        }
    }
}
